package tools

import (
	"crypto/sha256"
	"encoding/hex"
	"github.com/duke-git/lancet/v2/random"
)

func Uuid() string {
	v4, err := random.UUIdV4()
	if err != nil {
		panic(err)
		return ""
	}
	return v4
}

// 用固定的字符串生成一串uuid类似的字符串
func StringToUUID(str string) string {
	hasher := sha256.New()
	hasher.Write([]byte(str))
	return hex.EncodeToString(hasher.Sum(nil))
}
